home *** CD-ROM | disk | FTP | other *** search
- unit Testform;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, DOSInfo;
-
- type
- TForm1 = class(TForm)
- GroupBox1: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- FlopTypeB: TLabel;
- FlopTypeA: TLabel;
- FlopCount: TLabel;
- GroupBox2: TGroupBox;
- DriveList: TComboBox;
- Label4: TLabel;
- TheLabel: TEdit;
- Label5: TLabel;
- procedure FormCreate(Sender: TObject);
- procedure TheLabelKeyPress(Sender: TObject; var Key: Char);
- procedure DriveListChange(Sender: TObject);
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i: Char;
- begin
- { Set up the various labels }
- FlopCount.Caption := IntToStr (GetFloppyDriveCount);
- FlopTypeA.Caption := IntToStr (GetFloppyDriveType (0)) + ' KBytes';
- FlopTypeB.Caption := IntToStr (GetFloppyDriveType (1)) + ' KBytes';
-
- for i := 'C' to 'Z' do
- if GetDriveType (Ord (i) - Ord ('A')) = Drive_Fixed then
- DriveList.Items.Add (Format ('Drive %s:', [i]));
-
- DriveList.ItemIndex := 0;
- DriveListChange (Sender);
- end;
-
- procedure TForm1.TheLabelKeyPress(Sender: TObject; var Key: Char);
- begin
- Key := UpCase (Key);
- end;
-
- procedure TForm1.DriveListChange(Sender: TObject);
- var
- s: String;
- begin
- s := Copy (DriveList.Items [DriveList.ItemIndex], 7, 1);
- TheLabel.Text := GetDriveLabel (Ord (s[1]) - $40);
- end;
-
- procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
- var
- s: String;
- drive: Integer;
- begin
- if Ord (Key) = vk_Return then
- begin
- Key := #0;
- s := Copy (DriveList.Items [DriveList.ItemIndex], 7, 1);
- drive := Ord (s[1]) - $40;
- if (TheLabel.Text = '') and (GetDriveLabel (drive) <> '') then
- begin
- if MessageDlg (Format ('Remove drive label for drive %s: ?', [s [1]]),
- mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- SetDriveLabel (drive, '');
- end
- else SetDriveLabel (drive, TheLabel.Text);
- end;
- end;
-
- end.